package com.example.demo.servise.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.dao.bookdao_goods;
import com.example.demo.domain.goods;
import com.example.demo.servise.ibookGoods;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ibookgoodsimpl extends ServiceImpl<bookdao_goods, goods> implements ibookGoods {
    @Autowired
    private bookdao_goods bkd;

    @Override
    public IPage<goods> getPage(int currentPage, int pageSize) {
        IPage page=new Page(currentPage,pageSize);
        bkd.selectPage(page,null);
        return page;
    }

    @Override
    public IPage<goods> getPage(int currentPage, int pageSize, goods con) {
        LambdaQueryWrapper<goods> lqw =new LambdaQueryWrapper<goods>();
        lqw.like(con.getId()!=null,goods::getId,con.getId());
        lqw.like(Strings.isNotEmpty(con.getGoodsName()),goods::getGoodsName,con.getGoodsName());
        lqw.like(con.getGoodsPrice()!=null,goods::getGoodsPrice,con.getGoodsPrice());
        IPage page=new Page(currentPage,pageSize);
        bkd.selectPage(page,lqw);
        return page;
    }
}
